package com.tianji.remark.controller;

import com.tianji.api.dto.remark.LikeTimesQueryDTO;
import com.tianji.remark.domain.dto.LikeRecordFormDTO;
import com.tianji.remark.service.ILikedRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 点赞记录表 控制器
 * </p>
 *
 * @author xjs
 */
@Api(tags = "LikedRecord管理")
@RestController
@RequiredArgsConstructor
@RequestMapping("/likes")
public class LikedRecordController {

    private final ILikedRecordService likedRecordService;


    @PostMapping
    @ApiOperation("点赞或取消点赞")
    public void addLikeRecord(@Valid @RequestBody LikeRecordFormDTO recordDTO) {
        likedRecordService.addLikeRecord(recordDTO);
    }

    @ApiOperation("根据业务id和业务类型查询当前用户是否点过赞")
    @PostMapping("/queryByBizTypeAndIds")
    public LikeTimesQueryDTO queryByBizTypeAndIds(@RequestBody LikeTimesQueryDTO dto){
        return likedRecordService.queryByBizTypeAndIds(dto);
    }

}
